const path = require("path");
const polyfill = require("./webpack-plugin-polyfill/index");
// cryptojs-browserify
var input =
  "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\source\\crypto-browserify-master\\index.js";
var output =
  "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\dist\\crypto-browserify.js";

// cryptojs-browserify
// var input =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\source\\global-var-test\\browser.js";
// var output =
//   "C:\\Users\\Administrator\\Desktop\\jsonwebtoken-n2o\\n2o\\dist\\browser.js";
module.exports = {
  entry: input,
  mode: "development",
  //   experiments: {
  //     outputModule: true,
  //   },
  devtool: false,
  output: {
    // library: { type: "umd" },
    globalObject: "this",
    path: path.resolve(__dirname, "webpack-dist"),
    filename: "crypto-browser-development.js",
    libraryTarget: "umd",
    library: "cryptoNode",
  },
  //   externalsType: "module",
  externals: [
    {
      // ohos_util: "@ohos.util",
      // ohos_process: "@ohos.process",
      // ohos_hilog: "@ohos.hilog",
      //   buffer: "buffer",
      //   process: "process",
      //   events: "events",
      //   string_decoder: "string_decoder",
    },
    /^@ohos\..+/,
  ],
  plugins: [new polyfill()],

  // externals: [
  //   "@ohos.util",
  //   "@ohos.process",
  //   "@ohos.hilog",
  //   "@ohos.util",
  //   "buffer",
  //   "process",
  //   "events",
  //   "string_decoder",
  // ],
  resolve: {
    extensions: [".js", ".ts", ".esm.js"],
  },
};
